import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Kun extends Dinosaur{
    private BufferedImage image4;
    public Kun() {
        x = 50;
        y = LOWEST_Y;
        try {
            image1 = ImageIO.read(new File("image/kun1.png"));
            image2 = ImageIO.read(new File("image/kun2.png"));
            image3 = ImageIO.read(new File("image/kun3.png"));
            image4 = ImageIO.read(new File("image/kun4.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    protected void step() {
        stepTimer += FreshThread.fresh;
        if (downState) {
            image = image3;
            return;
        }
        if (jumpState) {
            image = image4;
            return;
        }
        int tmp = stepTimer / 150 % 3;
        if (tmp == 1) {
            image = image1;
        } else {
            image = image2;
        }
    }

    public Rectangle getFootBounds() { // 获取脚部边界对象
        if (downState) return new Rectangle(x + 10, y + 10, 70, 25);
        return new Rectangle(x + 15, y + 49, 29, 28); // 用于后续做碰撞检测
    }

    public Rectangle getHeadBounds() { // 获取头部边界对象
        return new Rectangle(x + 20, y + 5, 30, 22);
    }
}
